import unittest


""" Linear Bezier Path Tests """
def setup_linear_bezier_curve():
    import paths
    linpath = paths.linear_bezier()
    linpath.add_point(0,0)
    linpath.add_point(0,1)
    linpath.add_point(1,1)
    linpath.add_point(1,0)
    linpath.add_point(0,0)
    return linpath

class TestLinearBezierCurve(unittest.TestCase):
    def runTest(self):
        linpath = setup_linear_bezier_curve()
        assert linpath.total_length == 4        

class TestLinearBezierCurve2(unittest.TestCase):
    def runTest(self):
        linpath = setup_linear_bezier_curve()
        assert linpath.get_position(t=0.) == (0,0)

class TestLinearBezierCurve3(unittest.TestCase):
    def runTest(self):
        linpath = setup_linear_bezier_curve()
        assert linpath.get_position(t=0.25) == (0,1)

class TestLinearBezierCurve4(unittest.TestCase):
    def runTest(self):
        linpath = setup_linear_bezier_curve()
        assert linpath.get_position(t=0.5) == (1,1)

class TestLinearBezierCurve5(unittest.TestCase):
    def runTest(self):
        linpath = setup_linear_bezier_curve()
        assert linpath.get_position(t=1.0) == (0,0)

def get_linear_bezier_curve_tests():
    TS1 = TestLinearBezierCurve()
    TS2 = TestLinearBezierCurve2()
    TS3 = TestLinearBezierCurve3()
    TS4 = TestLinearBezierCurve4()
    TS5 = TestLinearBezierCurve5()
    testsuite = unittest.TestSuite((TS1,TS2,TS3,TS4,TS5))    
    return testsuite

def get_test():
    TS1 = get_linear_bezier_curve_tests()
    testsuite = unittest.TestSuite((TS1,))
    return testsuite

if __name__ == "__main__":
    runner = unittest.TextTestRunner()
    runner.run(get_test())
